﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Linq;
using System.Xml.Linq;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Tong;
using System.Data.SqlClient;
public partial class aspnet_testPargrameDir_NewsList : System.Web.UI.Page
{

    /// <summary>
    /// 数据操作通用类 实例 TextData
    /// </summary> 
    public TongUse TextData = new TongUse();

    /// <summary>
    /// 系统安装绝对路径
    /// </summary>
    public string Abs_Path = TongUse.SysPath;
    Tong.CreateNewType.CSharpExe CsharpExe = new Tong.CreateNewType.CSharpExe();

    /// <summary>
    /// 用户存放数据的临时表
    /// </summary>
    DataTable MyDt = new DataTable();

    /// <summary>
    /// 分页方法
    /// </summary>
    /// 
    public Tong.Fy.FenYe FY = new Tong.Fy.FenYe();
    
    //用于执行的代码
    string Text = "";
    protected void Page_Load(object sender, EventArgs e)
    {
        DataTable MyDtss = new DataTable();
        System.Runtime.Serialization.Formatters.Binary.BinaryFormatter MyBinary = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();
        System.IO.MemoryStream StreamMemory = new System.IO.MemoryStream();
        MyBinary.Serialize(StreamMemory, MyDtss);
       
        //exe
        ExexSqlClass();
    }

    /// <summary>
    /// 测试数据库操作
    /// </summary>
    void ExexSqlClass()
    {
        Tong.Data.DataOperTable<Tong.Data.Data_CX_NEWS> OperData = new Tong.Data.DataOperTable<Tong.Data.Data_CX_NEWS>();
        //OperData.Operate_inser(new Tong.Data.Data_CX_NEWS());
        OperData.OrderBy = " order by "+Tong.Data.Data_CX_NEWS._CX_NEWS_id + "  desc";
        Tong.Data.Data_CX_NEWS MyNews = new Tong.Data.Data_CX_NEWS();

        Tong.Data.Data_CX_NEWS[] MyDatas = OperData.Oper_SelectToObject(2);


        GridView1.DataSource = MyDatas;
        GridView1.DataBind();


        //Session["bid"] = (new Tong.Serialize.SerializeXML()).SerializeClassToXML(MyDatas[1]);

        //Response.Write((new Tong.Serialize.SerializeXML()).SerializeClassToXML(
            
        //    (new Tong.Serialize.SerializeXML()).SerializeXMLToClass(
        //    (new Tong.Serialize.SerializeXML()).SerializeClassToXML(
        //    MyDatas[1]
        //    ),typeof(Tong.Data.Data_CX_NEWS)
            
        //    )
            
            
        //    ));

        //OperData.Operate_inser((Tong.Data.Data_CX_NEWS)(new Tong.Serialize.SerializeXML()).SerializeXMLToClass(Session["bid"].ToString(),typeof(Tong.Data.Data_CX_NEWS)));


        //Response.Write(OperData.Oper_DelByDataKey(9276));

        Response.Write(OperData.ErrorInfo);

        Response.Write("输出动态给属性传值的代码"+(
            ((Conts)(new TestClass()
            ).StrinObj("啊不是吧真的输出了")).MyString
            
            ));

        //看看一条记录是不是存在
        Response.Write(OperData.Oper_Exists("看看整形前后的惊人对比吧！", Tong.Data.Data_CX_NEWS._CX_NEWS_Name));
        Response.Write(OperData.ErrorInfo);
    }

    void BindData()
    {
        System.CodeDom.Compiler.CompilerResults MYResults;//得到结果
        
        MYResults = CsharpExe.RunCode(new string[] { TextBox1.Text });
       
        foreach (string tempstr in MYResults.Output)
        {
            Response.Write(tempstr+"<br/>");
        }

        try
        {
            Type MyType = MYResults.CompiledAssembly.GetType(ExecClassName.Text.Trim());
            //执行方法
            Response.Write(
              (string)MyType.GetMethod(ExecFunName.Text.Trim()).Invoke(Activator.CreateInstance(MyType), null)
               +

                "<br/>"
                );


            Response.Write(string.Format("生成输出{0}<br/>全名{1}", MYResults.CompiledAssembly.CodeBase, MYResults.CompiledAssembly.FullName));
        }
        catch(Exception ex)
        {
            Response.Write(ex.Message + ex.StackTrace);
        }

    }

    protected void Button1_Click(object sender, EventArgs e)
    {
        BindData();
    }
}


public class ClassTest{

    public string GetGuid()
    {
        return Guid.NewGuid().ToString();
    }
}

namespace Tong.CreateNewType
{
    using System.Reflection;
    using System.Reflection.Emit;
    using Microsoft.CSharp;
    public class CSharpExe
    {
        /// <summary>
        /// 新建的编译器类型
        /// </summary>
        Microsoft.CSharp.CSharpCodeProvider MyCSharp = new CSharpCodeProvider();
        //实例化新的编写的参数
        System.CodeDom.Compiler.CompilerParameters MyCparmae = new System.CodeDom.Compiler.CompilerParameters();

        public System.CodeDom.Compiler.CompilerResults RunCode(string[] codes)
        {
            MyCparmae.GenerateInMemory = true;
            MyCparmae.GenerateExecutable = false;
            MyCparmae.IncludeDebugInformation = true;
            MyCparmae.CompilerOptions = "/target:library";//create type Libray

            MyCparmae.ReferencedAssemblies.Add("System.dll");
            MyCparmae.ReferencedAssemblies.Add("System.Web.dll");
            MyCparmae.ReferencedAssemblies.Add("System.Data.dll");
            MyCparmae.ReferencedAssemblies.Add("System.Xml.dll");
            

            return MyCSharp.CompileAssemblyFromSource(MyCparmae, codes);
        }
    }
}



namespace Tong.Data
{
    /// <summary>
    /// 用于数据表操作的接口
    /// </summary>
    /// <typeparam name="T">当前操作数据库表在 项目中的 映射 类型</typeparam>
    public interface IDataQueryTable<T>
    {

        /// <summary>
        /// 要初始化排序条件
        /// </summary>
        string OrderBy { get; set; }

        /// <summary>
        /// 出错的信息
        /// </summary>
        string ErrorInfo { get; set; }


        /// <summary>
        /// 用于实现插入的方法
        /// </summary>
        /// <param name="t">更新的对象</param>
        /// <returns></returns>
        bool Operate_inser(T t);

        /// <summary>
        /// 更新数据
        /// </summary>
        /// <param name="t">更新的对象</param>
        /// <returns></returns>
        bool Operate_update(T t);

        /// <summary>
        /// 传入 实例化的对象的主键值 此对象一定要指定主键
        /// </summary>
        /// <param name="t">实例化的数据库表对象</param>
        /// <returns></returns>
        DataSet Oper_Select(T DataTable_Obj);

        /// <summary>
        /// 传入一个 ID 值 用于得这个ID 值下的所有 数据
        /// </summary>
        /// <param name="ID">主键的ID值</param>
        /// <returns></returns>
        DataSet Oper_Select(string ID);

        /// <summary>
        /// 传入ID 和反回名 返回一个ID 的一个字段的值
        /// </summary>
        /// <param name="ID">ID</param>
        /// <param name="CoulmnName">字段名</param>
        /// <returns></returns>
        DataSet Oper_Select(string ID, string CoulmnName);

        /// <summary>
        ///  传入字段名得到这个字段在表里的记录,只有一个字段 
        ///  返回 DataSet
        /// </summary>
        /// <param name="CoulmnName">字段名  能在表里找到</param>
        /// <param name="RecordNum">读出条数</param>
        /// <returns></returns>
        DataSet Oper_Select(string CoulmnName, int RecordNum);


        /// <summary>
        /// 传入字段集合 返回条数据
        /// </summary>
        /// <param name="CoulmnName">字段的数据组 多个用</param>
        /// <param name="RecordNum">得到记录的条数</param>
        /// <returns></returns>
        DataSet OperSelectN(string[] CoulmnName, int RecordNum);

        /// <summary>
        ///  传入字段名得到这个字段在表里的记录,只有一个字段 
        ///  返回 DataSet
        /// </summary>
        /// <param name="CoulmnName">字段名  能在表里找到</param>
        /// <param name="RecordNum">读出条数</param>
        /// <param name="Where">条件 如 newsid!="" and 0=0 </param>
        /// <returns></returns>
        DataSet Oper_Select(string CoulmnName, int RecordNum, string Where);


        /// <summary>
        /// 传入字段集合 返回条数据
        /// </summary>
        /// <param name="CoulmnName">字段的数据组 多个用</param>
        /// <param name="RecordNum">得到记录的条数</param>
        /// <param name="Where">条件 如 newsid!="" and 0=0 </param>
        /// <returns></returns>
        DataSet OperSelectN(string[] CoulmnName, int RecordNum, string Where);

        /// <summary>
        /// 执行SQL语句 返回dataSet
        /// </summary>
        /// <typeparam name="Tab">数据表</typeparam>
        /// <param name="Sql">执行的SQL</param>
        /// <returns></returns>
        DataSet ExecuteQuery(string Sql);

        /// <summary>
        /// 传入删除的对象
        /// </summary>
        /// <param name="DataKeyValue">要删除的对象</param>
        bool Oper_Del(string DataKeyValue);

        /// <summary>
        /// 传入删除的主键值删除对象
        /// </summary>
        /// <param name="DataKeyValue">主键的值</param>
        bool Oper_DelByDataKey(string DataKeyValue);

        /// <summary>
        /// 传入要删除的主键的数组将一起删除
        /// </summary>
        /// <param name="DataKeyValue">主键的值</param>
        bool Oper_DelByDataKey(int DataKeyValue);

        /// <summary>
        /// 传入删除的主键值删除对象
        /// </summary>
        /// <param name="DataKeyValue">传入主键的值</param>
        bool Oper_DelByDataKey(DateTime DataKeyValue);

        /// <summary>
        /// 传入删除主键的数组值 string类型的数组
        /// </summary>
        /// <param name="DataKeyValue">传入删除的主键值 请使用 string[]数组</param>
        bool Oper_DelByDataKey(string[] DataKeyValue);

        /// <summary>
		/// 是否存在该记录
		/// </summary>
       /// <param name="DataKeyValue">传入主键的值</param>
        bool Oper_Exists(int DataKeyValue);

        /// <summary>
        /// 是否存在该记录
        /// </summary>
        /// <param name="DataKeyValue">传入主键的值</param>
        bool Oper_Exists(DateTime DataKeyValue);


        /// <summary>
        /// 是否存在该记录
        /// </summary>
        /// <param name="DataKeyValue">传入主键的值</param>
        bool Oper_Exists(string DataKeyValue);

        /// <summary>
        /// 是否存在该记录
        /// </summary>
        /// <param name="DataObject">传入的数据对像</param>
        bool Oper_Exists(T DataObject);

        /// <summary>
        /// 是否存在该记录 查找指定的栏目的指定的值
        /// </summary>
        /// <param name="ColumnValue">栏目值</param>
        /// <param name="Column">栏目名</param>
        /// <returns></returns>
        bool Oper_Exists(string ColumnValue, string Column);

        #region 数据转对象

        /// <summary>
        ///  传入读出数据的条数 条件
        ///  返回 Data_CX_NEWS 类型的数组
        /// </summary>
        /// <param name="RecordNum">读出条数</param>
        /// <param name="Where">条件 如 newsid!="" and 0=0 </param>
        /// <returns></returns>
        T[] Oper_SelectToObject(int RecordNum, string Where);

        /// <summary>
        ///  传入读出数据的条数 
        ///  返回 Data_CX_NEWS 类型的数组
        /// </summary>
        /// <param name="RecordNum">读出条数</param>
        /// <returns></returns>
        T[] Oper_SelectToObject(int RecordNum);

        #endregion






    }

    #region 定意表结构
    public interface IDataBaseTable
    {
        /// <summary>
        /// 表的主键名
        /// </summary>
        string TableDataKey { get; set; }

        /// <summary>
        /// 数据库表名
        /// </summary>
        string TableName { get; set; }
    }
    #endregion
}




namespace Tong.Data
{
    #region 实现操作的方法

    //public class DataOperTable<T> : IDataQueryTable<IDataBaseTable> where T : IDataBaseTable, new()
    //{
    //    /// <summary>
    //    /// 常用的数据库操作方法
    //    /// </summary>
    //    Tong.TongUse TextData = new Tong.TongUse();

    //    /// <summary>
    //    /// 当前传入类型的实例
    //    /// </summary>
    //    T Myt = new T();

    //    /// <summary>
    //    /// 数据库表映射类的公共属性
    //    /// </summary>
    //    private System.Reflection.PropertyInfo[] MyDataTableMembers;

    //    /// <summary>
    //    /// 用於資料庫操作的類型 聯接
    //    /// </summary>
    //    System.Data.SqlClient.SqlConnection MySql = new SqlConnection();

    //    #region IDataQueryTable<IDataBaseTable> 成员



    //    private string orderBy = "";
    //    /// <summary>
    //    /// 要初始化排序条件
    //    /// </summary>
    //    public string OrderBy
    //    {
    //        get
    //        {
    //            return orderBy;
    //        }
    //        set
    //        {
    //            orderBy = value;
    //        }
    //    }

    //    private string errorInfo = "";
    //    /// <summary>
    //    /// 出错的信息
    //    /// </summary>
    //    public string ErrorInfo
    //    {
    //        get
    //        {
    //            return errorInfo;
    //        }
    //        set
    //        {
    //            errorInfo = value;
    //        }
    //    }

    //    /// <summary>
    //    /// 用于实现插入的方法
    //    /// </summary>
    //    /// <param name="t">更新的对象</param>
    //    /// <returns></returns>
    //    public bool Operate_inser(IDataBaseTable t)
    //    {
    //        System.Reflection.PropertyInfo[] Propertys = GetMembers(t.GetType());//得到成员

    //        MySql.ConnectionString = TextData.MySql.ConnectionString;//建立新的实例
    //        if (MySql.State == System.Data.ConnectionState.Closed)
    //        {
    //            MySql.Open();
    //        }
    //        try
    //        {
    //            SqlCommand Cmd = new SqlCommand();
    //            Cmd.CommandType = CommandType.Text;
    //            Cmd.Connection = MySql;
    //            Cmd.CommandText = "INSERT INTO [" + t.TableName + "] (";
    //            foreach (System.Reflection.PropertyInfo Property in Propertys)
    //            {
    //                if (Property.Name != t.TableDataKey)
    //                {
    //                    Cmd.CommandText += "\t\t\t" + Property.Name + ",\r\n";
    //                }
    //            }


    //            Cmd.CommandText = Cmd.CommandText.Substring(0, Cmd.CommandText.Length - 3);
    //            Cmd.CommandText += "			)\r\n";
    //            Cmd.CommandText += "values( \r\n";

    //            foreach (System.Reflection.PropertyInfo Property in Propertys)
    //            {
    //                if (Property.Name != t.TableDataKey)
    //                {
    //                    Cmd.CommandText += "\t\t\t@" + Property.Name + ",\r\n";
    //                }
    //            }
    //            Cmd.CommandText = Cmd.CommandText.Substring(0, Cmd.CommandText.Length - 3);
    //            Cmd.CommandText += "\t\t\t ) \r\n";


    //            foreach (System.Reflection.PropertyInfo Property in Propertys)
    //            {
    //                if (Property.Name != t.TableDataKey)
    //                {
    //                    Cmd.Parameters.Add(new SqlParameter("@" + Property.Name, Property.GetValue(t, null)));
    //                }
    //            }

    //            Cmd.ExecuteNonQuery();
    //        }
    //        catch (Exception ex)
    //        {
    //            ErrorInfo += "执行 " + t.TableName + "表的添加操作时出现错误" + ex.Message;
    //            return false;
    //        }
    //        finally
    //        {
    //            MySql.Close();
    //        }

    //        return true;
            
    //    }

    //    /// <summary>
    //    /// 更新数据
    //    /// </summary>
    //    /// <param name="t">更新的对象</param>
    //    /// <returns></returns>
    //    public bool Operate_update(IDataBaseTable t)
    //    {

    //        System.Reflection.PropertyInfo[] Propertys = GetMembers(t.GetType());//得到成员

    //        MySql.ConnectionString = TextData.MySql.ConnectionString;//建立新的实例
    //        if (MySql.State == System.Data.ConnectionState.Closed)
    //        {
    //            MySql.Open();
    //        }
    //        try
    //        {
    //            SqlCommand Cmd = new SqlCommand();
    //            Cmd.CommandType = CommandType.Text;
    //            Cmd.Connection = MySql;
    //            Cmd.CommandText = "UPDATE  [" + t.TableName + "] Set ";
    //            foreach (System.Reflection.PropertyInfo Property in Propertys)
    //            {
    //                if (Property.Name != t.TableDataKey)
    //                {
    //                    Cmd.CommandText += "\t\t\t" + Property.Name + " = @"+Property.Name+",\r\n";
    //                }
    //            }
    //            //删除最后一个 " , "
    //            Cmd.CommandText = Cmd.CommandText.Substring(0, Cmd.CommandText.Length - 3);
    //            //加入条件看看 以主键的值更新
    //            Cmd.CommandText += "\r\n where [" + t.TableDataKey + "] = @" + t.TableDataKey + " \r\n";


    //            //给参数加入数据值
    //            foreach (System.Reflection.PropertyInfo Property in Propertys)
    //            {

    //               Cmd.Parameters.Add(new SqlParameter("@" + Property.Name, Property.GetValue(t, null)));
                
    //            }

    //            Cmd.ExecuteNonQuery();
    //        }
    //        catch (Exception ex)
    //        {
    //            ErrorInfo += "执行 " + t.TableName + "表的 更新 操作时出现错误" + ex.Message;
    //            return false;
    //        }
    //        finally
    //        {
    //            MySql.Close();
    //        }

    //        return true;
    //    }
    //    /// <summary>
    //    /// 传入 实例化的对象的主键值 此对象一定要指定主键
    //    /// </summary>
    //    /// <param name="t">实例化的数据库表对象</param>
    //    /// <returns></returns>
    //    public System.Data.DataSet Oper_Select(IDataBaseTable DataTable_Obj)
    //    {
    //        SqlDataAdapter MyDa = new SqlDataAdapter("", TextData.SqlConnStr);
    //        MyDa.SelectCommand.Connection = (new Tong.TongUse()).MySql;
    //        MyDa.SelectCommand.CommandType = CommandType.Text;

    //        #region 查询方法

    //        MyDa.SelectCommand.CommandText = "select * from  [" + DataTable_Obj.TableName + "] where  [" + DataTable_Obj.TableDataKey + "] = @" + DataTable_Obj.TableDataKey + "  " + OrderBy;

    //        MyDa.SelectCommand.Parameters.Add("@" + DataTable_Obj.TableDataKey, 
    //                                            //得到主键的值
    //                                            DataTable_Obj.GetType().GetProperty(DataTable_Obj.TableDataKey).GetValue(DataTable_Obj,null));
    //        #endregion


    //        DataSet MyDs = new DataSet();
    //        try
    //        {
    //            MyDa.Fill(MyDs);
    //        }
    //        catch (Exception ex)//資料填充時的異常處理
    //        {
    //            if (TextData.MySql.State == ConnectionState.Open)///ConnectionState 得到當前資料源聯接的狀態
    //            {
    //                TextData.MySql.Close();
    //            }
    //            MyDs = null;
    //            ErrorInfo += "执行查询操作ExecuteQuery(string Sql)时出现错误" + ex.Message;

    //        }

    //        if (TextData.MySql.State == ConnectionState.Open)///ConnectionState 得到當前資料源聯接的狀態
    //        {
    //            TextData.MySql.Close();

    //        }
    //        return MyDs;
    //    }

    //    /// <summary>
    //    /// 传入一个 ID 值 用于得这个ID 值下的所有 数据
    //    /// </summary>
    //    /// <param name="ID">主键的ID值</param>
    //    /// <returns></returns>
    //    public System.Data.DataSet Oper_Select(string ID)
    //    {
    //        SqlDataAdapter MyDa = new SqlDataAdapter("", TextData.SqlConnStr);
    //        MyDa.SelectCommand.Connection = (new Tong.TongUse()).MySql;
    //        MyDa.SelectCommand.CommandType = CommandType.Text;

    //        #region 查询方法
    //        MyDa.SelectCommand.CommandText = "select * from [" + Myt.TableName + "] where  [" + Myt.TableDataKey + "] =" + ID + "  " + OrderBy;
    //        #endregion


    //        DataSet MyDs = new DataSet();
    //        try
    //        {
    //            MyDa.Fill(MyDs);
    //        }
    //        catch (Exception ex)//資料填充時的異常處理
    //        {
    //            if (TextData.MySql.State == ConnectionState.Open)///ConnectionState 得到當前資料源聯接的狀態
    //            {
    //                TextData.MySql.Close();
    //            }
    //            MyDs = null;
    //            ErrorInfo += "执行查询操作ExecuteQuery(string Sql)时出现错误" + ex.Message;

    //        }

    //        if (TextData.MySql.State == ConnectionState.Open)///ConnectionState 得到當前資料源聯接的狀態
    //        {
    //            TextData.MySql.Close();

    //        }
    //        return MyDs;
    //    }
    //    /// <summary>
    //    /// 传入ID 和反回名 返回一个ID 的一个字段的值
    //    /// </summary>
    //    /// <param name="ID">ID</param>
    //    /// <param name="CoulmnName">字段名</param>
    //    /// <returns></returns>
    //    public System.Data.DataSet Oper_Select(string ID, string CoulmnName)
    //    {
    //        SqlDataAdapter MyDa = new SqlDataAdapter("", TextData.SqlConnStr);
    //        MyDa.SelectCommand.Connection = (new Tong.TongUse()).MySql;
    //        MyDa.SelectCommand.CommandType = CommandType.Text;

    //        #region 查询方法
    //        MyDa.SelectCommand.CommandText = "select " + CoulmnName + " from [" + Myt.TableName + "] where  [" + Myt.TableDataKey + "] =" + ID + "  " + OrderBy;
    //        #endregion


    //        DataSet MyDs = new DataSet();
    //        try
    //        {
    //            MyDa.Fill(MyDs);
    //        }
    //        catch (Exception ex)//資料填充時的異常處理
    //        {
    //            if (TextData.MySql.State == ConnectionState.Open)///ConnectionState 得到當前資料源聯接的狀態
    //            {
    //                TextData.MySql.Close();
    //            }
    //            MyDs = null;
    //            ErrorInfo += "执行查询操作ExecuteQuery(string Sql)时出现错误" + ex.Message;

    //        }

    //        if (TextData.MySql.State == ConnectionState.Open)///ConnectionState 得到當前資料源聯接的狀態
    //        {
    //            TextData.MySql.Close();

    //        }
    //        return MyDs;
    //    }

    //    /// <summary>
    //    ///  传入字段名得到这个字段在表里的记录,只有一个字段 
    //    ///  返回 DataSet
    //    /// </summary>
    //    /// <param name="CoulmnName">字段名  能在表里找到</param>
    //    /// <param name="RecordNum">读出条数</param>
    //    /// <returns></returns>
    //    public System.Data.DataSet Oper_Select(string CoulmnName, int RecordNum)
    //    {
    //        SqlDataAdapter MyDa = new SqlDataAdapter("", TextData.SqlConnStr);
    //        MyDa.SelectCommand.Connection = (new Tong.TongUse()).MySql;
    //        MyDa.SelectCommand.CommandType = CommandType.Text;

    //        #region 查询方法


    //        MyDa.SelectCommand.CommandText = "select Top (" + RecordNum + ")  " + CoulmnName + " from  [" + Myt.TableName + "]     " + OrderBy;

    //        #endregion




    //        DataSet MyDs = new DataSet();
    //        try
    //        {
    //            MyDa.Fill(MyDs);
    //        }
    //        catch (Exception ex)//資料填充時的異常處理
    //        {
    //            if (TextData.MySql.State == ConnectionState.Open)///ConnectionState 得到當前資料源聯接的狀態
    //            {
    //                TextData.MySql.Close();
    //            }
    //            MyDs = null;
    //            ErrorInfo += "执行查询操作   Oper_Select(string CoulmnName, int RecordNum)(string Sql)时出现错误" + ex.Message;

    //        }

    //        if (TextData.MySql.State == ConnectionState.Open)///ConnectionState 得到當前資料源聯接的狀態
    //        {
    //            TextData.MySql.Close();

    //        }
    //        return MyDs;
    //    }
    //    /// <summary>
    //    /// 传入字段集合 返回条数据
    //    /// </summary>
    //    /// <param name="CoulmnName">字段的数组  数组长度为0 为 得到全部的字段  </param>
    //    /// <param name="RecordNum">得到记录的条数</param>
    //    /// <returns></returns>
    //    public System.Data.DataSet OperSelectN(string[] CoulmnName, int RecordNum)
    //    {
            


    //        SqlDataAdapter MyDa = new SqlDataAdapter("", TextData.SqlConnStr);
    //        MyDa.SelectCommand.Connection = (new Tong.TongUse()).MySql;
    //        MyDa.SelectCommand.CommandType = CommandType.Text;


    //        #region 查询方法

    //        string Cloumn = "";
    //        for (int i = 0; i < CoulmnName.Length; i++)
    //        {
    //            Cloumn += CoulmnName[i].ToString() + ",";
    //        }

    //        if (Cloumn != "")
    //        {
    //            Cloumn = Cloumn.Substring(0, Cloumn.Length - 1);
    //        }
    //        else
    //        {
    //            Cloumn = "*";
    //        }

    //        MyDa.SelectCommand.CommandText = "select top (" + RecordNum + ") " + Cloumn + " from  [" + Myt.TableName + "]    " + OrderBy;

    //        #endregion


    //        DataSet MyDs = new DataSet();
    //        try
    //        {
    //            MyDa.Fill(MyDs);
    //        }
    //        catch (Exception ex)//資料填充時的異常處理
    //        {
    //            if (TextData.MySql.State == ConnectionState.Open)///ConnectionState 得到當前資料源聯接的狀態
    //            {
    //                TextData.MySql.Close();
    //            }
    //            MyDs = null;
    //            ErrorInfo += "执行查询操作   Oper_Select(string CoulmnName, int RecordNum)(string Sql)时出现错误" + ex.Message;

    //        }

    //        if (TextData.MySql.State == ConnectionState.Open)///ConnectionState 得到當前資料源聯接的狀態
    //        {
    //            TextData.MySql.Close();

    //        }
    //        return MyDs;
    //    }
    //    /// <summary>
    //    ///  传入多个字段名得到这个字段在表里的记录,只有一个字段 
    //    ///  返回 DataSet
    //    /// </summary>
    //    /// <param name="CoulmnName">字段名  能在表里找到</param>
    //    /// <param name="RecordNum">读出条数</param>
    //    /// <param name="Where">条件 如 newsid!="" and 0=0 </param>
    //    /// <returns></returns>
    //    public System.Data.DataSet Oper_Select(string CoulmnName, int RecordNum, string Where)
    //    {


    //        SqlDataAdapter MyDa = new SqlDataAdapter("", TextData.SqlConnStr);
    //        MyDa.SelectCommand.Connection = (new Tong.TongUse()).MySql;
    //        MyDa.SelectCommand.CommandType = CommandType.Text;

    //        #region CX_Resume 的查询方法
    //        MyDa.SelectCommand.CommandText = "select Top (" + RecordNum + ")  " + CoulmnName + " from  [" + Myt.TableName + "]   where " + Where + "  " + OrderBy;
    //        #endregion




    //        DataSet MyDs = new DataSet();
    //        try
    //        {
    //            MyDa.Fill(MyDs);
    //        }
    //        catch (Exception ex)//資料填充時的異常處理
    //        {
    //            if (TextData.MySql.State == ConnectionState.Open)///ConnectionState 得到當前資料源聯接的狀態
    //            {
    //                TextData.MySql.Close();
    //            }
    //            MyDs = null;
    //            ErrorInfo += "执行查询操作   Oper_Select(string CoulmnName, int RecordNum)(string Sql)时出现错误" + ex.Message;

    //        }

    //        if (TextData.MySql.State == ConnectionState.Open)///ConnectionState 得到當前資料源聯接的狀態
    //        {
    //            TextData.MySql.Close();

    //        }
    //        return MyDs;



    //    }
    //    /// <summary>
    //    ///  传入字段集合 返回条数据
    //    ///  返回 DataSet
    //    /// </summary>
    //    /// <param name="CoulmnName">字段名  能在表里找到 字段的数组  数组长度为0 为 得到全部的字段</param>
    //    /// <param name="RecordNum">读出条数</param>
    //    /// <param name="Where">条件 如 newsid!="" and 0=0 </param>
    //    /// <returns></returns>
    //    public System.Data.DataSet OperSelectN(string[] CoulmnName, int RecordNum, string Where)
    //    {



    //        SqlDataAdapter MyDa = new SqlDataAdapter("", TextData.SqlConnStr);
    //        MyDa.SelectCommand.Connection = (new Tong.TongUse()).MySql;
    //        MyDa.SelectCommand.CommandType = CommandType.Text;

    //        #region 查询方法
    //        string Cloumn = "";
    //        for (int i = 0; i < CoulmnName.Length; i++)
    //        {
    //            Cloumn += CoulmnName[i].ToString() + ",";
    //        }

    //        if (Cloumn != "")
    //        {
    //            Cloumn = Cloumn.Substring(0, Cloumn.Length - 1);
    //        }
    //        else
    //        {
    //            Cloumn = "*";
    //        }
    //        MyDa.SelectCommand.CommandText = "select top (" + RecordNum + ") " + Cloumn + " from  [" + Myt.TableName + "]   where " + Where + "   " + OrderBy;
    //        #endregion

    //        DataSet MyDs = new DataSet();
    //        try
    //        {
    //            MyDa.Fill(MyDs);
    //        }
    //        catch (Exception ex)//資料填充時的異常處理
    //        {
    //            if (TextData.MySql.State == ConnectionState.Open)///ConnectionState 得到當前資料源聯接的狀態
    //            {
    //                TextData.MySql.Close();
    //            }
    //            MyDs = null;
    //            ErrorInfo += "执行查询操作   Oper_Select(string CoulmnName, int RecordNum)(string Sql)时出现错误" + ex.Message;

    //        }

    //        if (TextData.MySql.State == ConnectionState.Open)///ConnectionState 得到當前資料源聯接的狀態
    //        {
    //            TextData.MySql.Close();

    //        }
    //        return MyDs;

    //    }

    //    public System.Data.DataSet ExecuteQuery(string Sql)
    //    {
    //        SqlDataAdapter MyDa = new SqlDataAdapter("", TextData.SqlConnStr);
    //        MyDa.SelectCommand.Connection = TextData.MySql;
    //        MyDa.SelectCommand.CommandType = CommandType.Text;

    //        #region CX_Resume 的查询方法
    //        MyDa.SelectCommand.CommandText = Sql;
    //        #endregion



    //        DataSet MyDs = new DataSet();
    //        try
    //        {
    //            MyDa.Fill(MyDs);
    //        }
    //        catch (Exception ex)//資料填充時的異常處理
    //        {
    //            if (TextData.MySql.State == ConnectionState.Open)///ConnectionState 得到當前資料源聯接的狀態
    //            {
    //                TextData.MySql.Close();
    //            }
    //            MyDs = null;
    //            ErrorInfo += "执行查询操作ExecuteQuery(string Sql)时出现错误" + ex.Message;

    //        }

    //        if (TextData.MySql.State == ConnectionState.Open)///ConnectionState 得到當前資料源聯接的狀態
    //        {
    //            TextData.MySql.Close();

    //        }
    //        return MyDs;
    //    }

    //    public bool Oper_Del(string DataKeyValue)
    //    {
    //        bool tempvalue = false;

    //        //执行删除
    //        ExecuteQuery("delete * from [" + Myt.TableName + "] where  [" + Myt.TableDataKey + "] =" + DataKeyValue + "  " + OrderBy);

    //        if (errorInfo == "")
    //        {
    //            tempvalue = true;
    //        }

    //        return tempvalue;
            
    //    }

    //    public bool Oper_DelByDataKey(string DataKeyValue)
    //    {
    //        bool tempvalue = false;

    //        //执行删除
    //        try
    //        {
    //            int.Parse(DataKeyValue);
    //            ExecuteQuery("delete * from [" + Myt.TableName + "] where  [" + Myt.TableDataKey + "] =" + DataKeyValue + "  " + OrderBy);
                
    //        }
    //        catch
    //        {
    //            errorInfo = "";
    //            ExecuteQuery("delete * from [" + Myt.TableName + "] where  [" + Myt.TableDataKey + "] = '" + DataKeyValue + "'  " + OrderBy);
    //        }



    //        if (errorInfo == "")
    //        {
    //            tempvalue = true;
    //        }

    //        return tempvalue;
    //    }

    //    public bool Oper_DelByDataKey(int DataKeyValue)
    //    {
    //        bool tempvalue = false;

    //        //执行删除
    //        ExecuteQuery("delete * from [" + Myt.TableName + "] where  [" + Myt.TableDataKey + "] =" + DataKeyValue + "  " + OrderBy);

    //        if (errorInfo == "")
    //        {
    //            tempvalue = true;
    //        }

    //        return tempvalue;
    //    }

    //    public bool Oper_DelByDataKey(DateTime DataKeyValue)
    //    {
    //        bool tempvalue = false;

    //        //执行删除
    //        ExecuteQuery("delete * from [" + Myt.TableName + "] where  [" + Myt.TableDataKey + "] = '" + DataKeyValue + "'  " + OrderBy);

    //        if (errorInfo == "")
    //        {
    //            tempvalue = true;
    //        }

    //        return tempvalue;
    //    }

    //    public bool Oper_DelByDataKey(string[] DataKeyValue)
    //    {
    //        throw new NotImplementedException();
    //    }
    //    #region 数据转对象
    //    /// <summary>
    //    ///  传入读出数据的条数 条件
    //    ///  返回  类型的数组
    //    /// </summary>
    //    /// <param name="RecordNum">读出条数</param>
    //    /// <param name="Where">条件 如 newsid!="" and 0=0 </param>
    //    /// <returns></returns>
    //    public IDataBaseTable[] Oper_SelectToObject(int RecordNum, string Where)
    //    {
    //        return (IDataBaseTable[])ConvertToObject(OperSelectN(new String[] { }, RecordNum, Where));
    //    }
    //    /// <summary>
    //    ///  传入读出数据的条数 
    //    ///  返回  类型的数组
    //    /// </summary>
    //    /// <param name="RecordNum">读出条数</param>
    //    /// <returns></returns>
    //    public IDataBaseTable[] Oper_SelectToObject(int RecordNum)
    //    {
    //        return (IDataBaseTable[])ConvertToObject(OperSelectN(new String[] { }, RecordNum));
    //    }
    //    #endregion



    //    #endregion

    //    /// <summary>
    //    /// 把对应表的数据转成对象
    //    /// </summary>
    //    /// <param name="MyDs">传入的dataset</param>
    //    /// <returns></returns>
    //    private IDataBaseTable[] ConvertToObject(DataSet MyDs)
    //    {
    //        DataTable Mydt = MyDs.Tables[0];

    //        //定义一个方法用于显示数据 类型的集合
    //        IDataBaseTable[] p = new IDataBaseTable[1];
    //        if (Mydt.Rows.Count == 0)
    //        {
    //            p[0] = Myt;
    //        }
    //        else
    //        {
    //            p = new IDataBaseTable[Mydt.Rows.Count];
    //        }

    //        try
    //        {
    //            for (int i = 0; i < Mydt.Rows.Count; i++)
    //            {

    //                object Mydato = Activator.CreateInstance(Myt.GetType());//实例化新对像

    //                #region 实现转换的方法

    //                ///开始使用方法传入属性值
    //                foreach (System.Reflection.PropertyInfo Proper in Myt.GetType().GetProperties())
    //                {
    //                    if (Proper.Name != "TableName" && Proper.Name != "TableDataKey")//删除接口的两个默认属性
    //                    {
    //                        Mydato.GetType().GetProperty(Proper.Name).SetValue(Mydato,
    //                            //传值
    //                            //  Mydt.Rows[i][Proper.Name].GetType().ToString() 得到当前的类型
    //                            // Myt.GetType().GetProperty(Proper.Name).GetValue(Myt, null);//返回默认值
    //                            // Mydt.Rows[i][Proper.Name] 得到当前的值
    //                            Mydt.Rows[i][Proper.Name].GetType().ToString() == System.DBNull.Value.GetType().ToString() ? Myt.GetType().GetProperty(Proper.Name).GetValue(Myt, null) : Mydt.Rows[i][Proper.Name]
    //                            , null);
    //                    }
    //                    else
    //                    {
    //                        //设定值
    //                        Mydato.GetType().GetProperty(Proper.Name).SetValue(Mydato,
    //                            Myt.GetType().GetProperty(Proper.Name).GetValue(Myt, null),
    //                            null);
    //                    }
    //                }

    //                #endregion
    //                p[i] = (IDataBaseTable)Mydato;


    //            }
    //        }
    //        catch (Exception ex)
    //        {
    //            errorInfo += "执行  把对应表的数据转成对象时出现错误" + ex.Message + ex.Source;
    //        }

    //        return p;
    //    }

    //    /// <summary>
    //    /// 得到传入对像的成员 返回下面所有的属性
    //    /// </summary>
    //    /// <param name="type">传入 实现 IDataBaseTable接口的数据库操作对像 </param>
    //    /// <returns></returns>
    //    private System.Reflection.PropertyInfo[] GetMembers(Type type)
    //    {

    //        MyDataTableMembers = new System.Reflection.PropertyInfo[type.GetProperties().Length - 2];//设定初始长度
    //        int i = 0;
    //        foreach (System.Reflection.PropertyInfo Proper in type.GetProperties())
    //        {
    //            if (Proper.Name != "TableName" && Proper.Name != "TableDataKey")//删除接口的两个默认属性
    //            {
    //                MyDataTableMembers[i] = Proper;
    //            }
    //            i++;
    //        }

    //        return MyDataTableMembers;
    //    }

    //}
    #endregion

    /// <summary>
    /// 用于实现操作的方法
    /// </summary>
    /// <typeparam name="T">传入实现 IDataBaseTable 的数据表</typeparam>
    [System.ComponentModel.DataObject]
    public class DataOperTable<T> : IDataQueryTable<T> where T : IDataBaseTable, new()
    {

        /// <summary>
        /// 常用的数据库操作方法
        /// </summary>
        Tong.TongUse TextData = new Tong.TongUse();

        /// <summary>
        /// 当前传入类型的实例
        /// </summary>
        T Myt = new T();

        /// <summary>
        /// 数据库表映射类的公共属性
        /// </summary>
        private System.Reflection.PropertyInfo[] MyDataTableMembers;

        /// <summary>
        /// 用於資料庫操作的類型 聯接
        /// </summary>
        System.Data.SqlClient.SqlConnection MySql = new SqlConnection();

        #region IDataQueryTable<T> 成员



        private string orderBy = "";
        /// <summary>
        /// 要初始化排序条件
        /// </summary>
        public string OrderBy
        {
            get
            {
                return orderBy;
            }
            set
            {
                orderBy = value;
            }
        }

        private string errorInfo = "";
        /// <summary>
        /// 出错的信息
        /// </summary>
        public string ErrorInfo
        {
            get
            {
                return errorInfo;
            }
            set
            {
                errorInfo = value;
            }
        }

        /// <summary>
        /// 用于实现插入的方法
        /// </summary>
        /// <param name="t">更新的对象</param>
        /// <returns></returns>
        public bool Operate_inser(T t)
        {
            System.Reflection.PropertyInfo[] Propertys = GetMembers(t.GetType());//得到成员

            MySql.ConnectionString = TextData.MySql.ConnectionString;//建立新的实例
            if (MySql.State == System.Data.ConnectionState.Closed)
            {
                MySql.Open();
            }
            try
            {
                SqlCommand Cmd = new SqlCommand();
                Cmd.CommandType = CommandType.Text;
                Cmd.Connection = MySql;
                Cmd.CommandText = "INSERT INTO [" + t.TableName + "] (";
                foreach (System.Reflection.PropertyInfo Property in Propertys)
                {
                    if (Property.Name != t.TableDataKey)
                    {
                        Cmd.CommandText += "\t\t\t" + Property.Name + ",\r\n";
                    }
                }


                Cmd.CommandText = Cmd.CommandText.Substring(0, Cmd.CommandText.Length - 3);
                Cmd.CommandText += "			)\r\n";
                Cmd.CommandText += "values( \r\n";

                foreach (System.Reflection.PropertyInfo Property in Propertys)
                {
                    if (Property.Name != t.TableDataKey)
                    {
                        Cmd.CommandText += "\t\t\t@" + Property.Name + ",\r\n";
                    }
                }
                Cmd.CommandText = Cmd.CommandText.Substring(0, Cmd.CommandText.Length - 3);
                Cmd.CommandText += "\t\t\t ) \r\n";


                foreach (System.Reflection.PropertyInfo Property in Propertys)
                {
                    if (Property.Name != t.TableDataKey)
                    {
                        Cmd.Parameters.Add(new SqlParameter("@" + Property.Name, Property.GetValue(t, null)));
                    }
                }

                Cmd.ExecuteNonQuery();
            }
            catch (Exception ex)
            {
                ErrorInfo += "执行 " + t.TableName + "表的添加操作时出现错误" + ex.Message;
                return false;
            }
            finally
            {
                MySql.Close();
            }

            return true;

        }

        /// <summary>
        /// 更新数据
        /// </summary>
        /// <param name="t">更新的对象</param>
        /// <returns></returns>
        public bool Operate_update(T t)
        {

            System.Reflection.PropertyInfo[] Propertys = GetMembers(t.GetType());//得到成员

            MySql.ConnectionString = TextData.MySql.ConnectionString;//建立新的实例
            if (MySql.State == System.Data.ConnectionState.Closed)
            {
                MySql.Open();
            }
            try
            {
                SqlCommand Cmd = new SqlCommand();
                Cmd.CommandType = CommandType.Text;
                Cmd.Connection = MySql;
                Cmd.CommandText = "UPDATE  [" + t.TableName + "] Set ";
                foreach (System.Reflection.PropertyInfo Property in Propertys)
                {
                    if (Property.Name != t.TableDataKey)
                    {
                        Cmd.CommandText += "\t\t\t" + Property.Name + " = @" + Property.Name + ",\r\n";
                    }
                }
                //删除最后一个 " , "
                Cmd.CommandText = Cmd.CommandText.Substring(0, Cmd.CommandText.Length - 3);
                //加入条件看看 以主键的值更新
                Cmd.CommandText += "\r\n where [" + t.TableDataKey + "] = @" + t.TableDataKey + " \r\n";


                //给参数加入数据值
                foreach (System.Reflection.PropertyInfo Property in Propertys)
                {

                    Cmd.Parameters.Add(new SqlParameter("@" + Property.Name, Property.GetValue(t, null)));

                }

                Cmd.ExecuteNonQuery();
            }
            catch (Exception ex)
            {
                ErrorInfo += "执行 " + t.TableName + "表的 更新 操作时出现错误" + ex.Message;
                return false;
            }
            finally
            {
                MySql.Close();
            }

            return true;
        }
        /// <summary>
        /// 传入 实例化的对象的主键值 此对象一定要指定主键
        /// </summary>
        /// <param name="t">实例化的数据库表对象</param>
        /// <returns></returns>
        public System.Data.DataSet Oper_Select(T DataTable_Obj)
        {
            SqlDataAdapter MyDa = new SqlDataAdapter("", TextData.SqlConnStr);
            MyDa.SelectCommand.Connection = (new Tong.TongUse()).MySql;
            MyDa.SelectCommand.CommandType = CommandType.Text;

            #region 查询方法

            MyDa.SelectCommand.CommandText = "select * from  [" + DataTable_Obj.TableName + "] where  [" + DataTable_Obj.TableDataKey + "] = @" + DataTable_Obj.TableDataKey + "  " + OrderBy;

            MyDa.SelectCommand.Parameters.Add("@" + DataTable_Obj.TableDataKey,
                //得到主键的值
                                                DataTable_Obj.GetType().GetProperty(DataTable_Obj.TableDataKey).GetValue(DataTable_Obj, null));
            #endregion


            DataSet MyDs = new DataSet();
            try
            {
                MyDa.Fill(MyDs);
            }
            catch (Exception ex)//資料填充時的異常處理
            {
                if (TextData.MySql.State == ConnectionState.Open)///ConnectionState 得到當前資料源聯接的狀態
                {
                    TextData.MySql.Close();
                }
                MyDs = null;
                ErrorInfo += "执行查询操作ExecuteQuery(string Sql)时出现错误" + ex.Message;

            }

            if (TextData.MySql.State == ConnectionState.Open)///ConnectionState 得到當前資料源聯接的狀態
            {
                TextData.MySql.Close();

            }
            return MyDs;
        }

        /// <summary>
        /// 传入一个 ID 值 用于得这个ID 值下的所有 数据
        /// </summary>
        /// <param name="ID">主键的ID值</param>
        /// <returns></returns>
        public System.Data.DataSet Oper_Select(string ID)
        {
            SqlDataAdapter MyDa = new SqlDataAdapter("", TextData.SqlConnStr);
            MyDa.SelectCommand.Connection = (new Tong.TongUse()).MySql;
            MyDa.SelectCommand.CommandType = CommandType.Text;

            #region 查询方法
            MyDa.SelectCommand.CommandText = "select * from [" + Myt.TableName + "] where  [" + Myt.TableDataKey + "] =" + ID + "  " + OrderBy;
            #endregion


            DataSet MyDs = new DataSet();
            try
            {
                MyDa.Fill(MyDs);
            }
            catch (Exception ex)//資料填充時的異常處理
            {
                if (TextData.MySql.State == ConnectionState.Open)///ConnectionState 得到當前資料源聯接的狀態
                {
                    TextData.MySql.Close();
                }
                MyDs = null;
                ErrorInfo += "执行查询操作ExecuteQuery(string Sql)时出现错误" + ex.Message;

            }

            if (TextData.MySql.State == ConnectionState.Open)///ConnectionState 得到當前資料源聯接的狀態
            {
                TextData.MySql.Close();

            }
            return MyDs;
        }
        /// <summary>
        /// 传入ID 和反回名 返回一个ID 的一个字段的值
        /// </summary>
        /// <param name="ID">ID</param>
        /// <param name="CoulmnName">字段名</param>
        /// <returns></returns>
        public System.Data.DataSet Oper_Select(string ID, string CoulmnName)
        {
            SqlDataAdapter MyDa = new SqlDataAdapter("", TextData.SqlConnStr);
            MyDa.SelectCommand.Connection = (new Tong.TongUse()).MySql;
            MyDa.SelectCommand.CommandType = CommandType.Text;

            #region 查询方法
            MyDa.SelectCommand.CommandText = "select " + CoulmnName + " from [" + Myt.TableName + "] where  [" + Myt.TableDataKey + "] =" + ID + "  " + OrderBy;
            #endregion


            DataSet MyDs = new DataSet();
            try
            {
                MyDa.Fill(MyDs);
            }
            catch (Exception ex)//資料填充時的異常處理
            {
                if (TextData.MySql.State == ConnectionState.Open)///ConnectionState 得到當前資料源聯接的狀態
                {
                    TextData.MySql.Close();
                }
                MyDs = null;
                ErrorInfo += "执行查询操作ExecuteQuery(string Sql)时出现错误" + ex.Message;

            }

            if (TextData.MySql.State == ConnectionState.Open)///ConnectionState 得到當前資料源聯接的狀態
            {
                TextData.MySql.Close();

            }
            return MyDs;
        }

        /// <summary>
        ///  传入字段名得到这个字段在表里的记录,只有一个字段 
        ///  返回 DataSet
        /// </summary>
        /// <param name="CoulmnName">字段名  能在表里找到</param>
        /// <param name="RecordNum">读出条数</param>
        /// <returns></returns>
        public System.Data.DataSet Oper_Select(string CoulmnName, int RecordNum)
        {
            SqlDataAdapter MyDa = new SqlDataAdapter("", TextData.SqlConnStr);
            MyDa.SelectCommand.Connection = (new Tong.TongUse()).MySql;
            MyDa.SelectCommand.CommandType = CommandType.Text;

            #region 查询方法


            MyDa.SelectCommand.CommandText = "select Top (" + RecordNum + ")  " + CoulmnName + " from  [" + Myt.TableName + "]     " + OrderBy;

            #endregion




            DataSet MyDs = new DataSet();
            try
            {
                MyDa.Fill(MyDs);
            }
            catch (Exception ex)//資料填充時的異常處理
            {
                if (TextData.MySql.State == ConnectionState.Open)///ConnectionState 得到當前資料源聯接的狀態
                {
                    TextData.MySql.Close();
                }
                MyDs = null;
                ErrorInfo += "执行查询操作   Oper_Select(string CoulmnName, int RecordNum)(string Sql)时出现错误" + ex.Message;

            }

            if (TextData.MySql.State == ConnectionState.Open)///ConnectionState 得到當前資料源聯接的狀態
            {
                TextData.MySql.Close();

            }
            return MyDs;
        }
        /// <summary>
        /// 传入字段集合 返回条数据
        /// </summary>
        /// <param name="CoulmnName">字段的数组  数组长度为0 为 得到全部的字段  </param>
        /// <param name="RecordNum">得到记录的条数</param>
        /// <returns></returns>
        public System.Data.DataSet OperSelectN(string[] CoulmnName, int RecordNum)
        {



            SqlDataAdapter MyDa = new SqlDataAdapter("", TextData.SqlConnStr);
            MyDa.SelectCommand.Connection = (new Tong.TongUse()).MySql;
            MyDa.SelectCommand.CommandType = CommandType.Text;


            #region 查询方法

            string Cloumn = "";
            for (int i = 0; i < CoulmnName.Length; i++)
            {
                Cloumn += CoulmnName[i].ToString() + ",";
            }

            if (Cloumn != "")
            {
                Cloumn = Cloumn.Substring(0, Cloumn.Length - 1);
            }
            else
            {
                Cloumn = "*";
            }

            MyDa.SelectCommand.CommandText = "select top (" + RecordNum + ") " + Cloumn + " from  [" + Myt.TableName + "]    " + OrderBy;

            #endregion


            DataSet MyDs = new DataSet();
            try
            {
                MyDa.Fill(MyDs);
            }
            catch (Exception ex)//資料填充時的異常處理
            {
                if (TextData.MySql.State == ConnectionState.Open)///ConnectionState 得到當前資料源聯接的狀態
                {
                    TextData.MySql.Close();
                }
                MyDs = null;
                ErrorInfo += "执行查询操作   Oper_Select(string CoulmnName, int RecordNum)(string Sql)时出现错误" + ex.Message;

            }

            if (TextData.MySql.State == ConnectionState.Open)///ConnectionState 得到當前資料源聯接的狀態
            {
                TextData.MySql.Close();

            }
            return MyDs;
        }
        /// <summary>
        ///  传入多个字段名得到这个字段在表里的记录,只有一个字段 
        ///  返回 DataSet
        /// </summary>
        /// <param name="CoulmnName">字段名  能在表里找到</param>
        /// <param name="RecordNum">读出条数</param>
        /// <param name="Where">条件 如 newsid!="" and 0=0 </param>
        /// <returns></returns>
        public System.Data.DataSet Oper_Select(string CoulmnName, int RecordNum, string Where)
        {


            SqlDataAdapter MyDa = new SqlDataAdapter("", TextData.SqlConnStr);
            MyDa.SelectCommand.Connection = (new Tong.TongUse()).MySql;
            MyDa.SelectCommand.CommandType = CommandType.Text;

            #region CX_Resume 的查询方法
            MyDa.SelectCommand.CommandText = "select Top (" + RecordNum + ")  " + CoulmnName + " from  [" + Myt.TableName + "]   where " + Where + "  " + OrderBy;
            #endregion




            DataSet MyDs = new DataSet();
            try
            {
                MyDa.Fill(MyDs);
            }
            catch (Exception ex)//資料填充時的異常處理
            {
                if (TextData.MySql.State == ConnectionState.Open)///ConnectionState 得到當前資料源聯接的狀態
                {
                    TextData.MySql.Close();
                }
                MyDs = null;
                ErrorInfo += "执行查询操作   Oper_Select(string CoulmnName, int RecordNum)(string Sql)时出现错误" + ex.Message;

            }

            if (TextData.MySql.State == ConnectionState.Open)///ConnectionState 得到當前資料源聯接的狀態
            {
                TextData.MySql.Close();

            }
            return MyDs;



        }
        /// <summary>
        ///  传入字段集合 返回条数据
        ///  返回 DataSet
        /// </summary>
        /// <param name="CoulmnName">字段名  能在表里找到 字段的数组  数组长度为0 为 得到全部的字段</param>
        /// <param name="RecordNum">读出条数</param>
        /// <param name="Where">条件 如 newsid!="" and 0=0 </param>
        /// <returns></returns>
        public System.Data.DataSet OperSelectN(string[] CoulmnName, int RecordNum, string Where)
        {



            SqlDataAdapter MyDa = new SqlDataAdapter("", TextData.SqlConnStr);
            MyDa.SelectCommand.Connection = (new Tong.TongUse()).MySql;
            MyDa.SelectCommand.CommandType = CommandType.Text;

            #region 查询方法
            string Cloumn = "";
            for (int i = 0; i < CoulmnName.Length; i++)
            {
                Cloumn += CoulmnName[i].ToString() + ",";
            }

            if (Cloumn != "")
            {
                Cloumn = Cloumn.Substring(0, Cloumn.Length - 1);
            }
            else
            {
                Cloumn = "*";
            }
            MyDa.SelectCommand.CommandText = "select top (" + RecordNum + ") " + Cloumn + " from  [" + Myt.TableName + "]   where " + Where + "   " + OrderBy;
            #endregion

            DataSet MyDs = new DataSet();
            try
            {
                MyDa.Fill(MyDs);
            }
            catch (Exception ex)//資料填充時的異常處理
            {
                if (TextData.MySql.State == ConnectionState.Open)///ConnectionState 得到當前資料源聯接的狀態
                {
                    TextData.MySql.Close();
                }
                MyDs = null;
                ErrorInfo += "执行查询操作   Oper_Select(string CoulmnName, int RecordNum)(string Sql)时出现错误" + ex.Message;

            }

            if (TextData.MySql.State == ConnectionState.Open)///ConnectionState 得到當前資料源聯接的狀態
            {
                TextData.MySql.Close();

            }
            return MyDs;

        }
        /// <summary>
        /// 执行SQL语句 返回dataSet
        /// </summary>
        /// <typeparam name="Tab">数据表</typeparam>
        /// <param name="Sql">执行的SQL</param>
        /// <returns></returns>
        public System.Data.DataSet ExecuteQuery(string Sql)
        {
            SqlDataAdapter MyDa = new SqlDataAdapter("", TextData.SqlConnStr);
            MyDa.SelectCommand.Connection = TextData.MySql;
            MyDa.SelectCommand.CommandType = CommandType.Text;

            #region CX_Resume 的查询方法
            MyDa.SelectCommand.CommandText = Sql;
            #endregion



            DataSet MyDs = new DataSet();
            try
            {
                MyDa.Fill(MyDs);
            }
            catch (Exception ex)//資料填充時的異常處理
            {
                if (TextData.MySql.State == ConnectionState.Open)///ConnectionState 得到當前資料源聯接的狀態
                {
                    TextData.MySql.Close();
                }
                MyDs = null;
                ErrorInfo += "执行查询操作ExecuteQuery(string Sql)时出现错误" + ex.Message;

            }

            if (TextData.MySql.State == ConnectionState.Open)///ConnectionState 得到當前資料源聯接的狀態
            {
                TextData.MySql.Close();

            }
            return MyDs;
        }
        /// <summary>
        /// 传入删除的对象
        /// </summary>
        /// <param name="DataKeyValue">要删除的对象</param>
        public bool Oper_Del(string DataKeyValue)
        {
            bool tempvalue = false;

            //执行删除
            ExecuteQuery("delete  [" + Myt.TableName + "] where  [" + Myt.TableDataKey + "] =" + DataKeyValue + "  ");

            if (errorInfo == "")
            {
                tempvalue = true;
            }

            return tempvalue;

        }
        /// <summary>
        /// 传入删除的主键值删除对象
        /// </summary>
        /// <param name="DataKeyValue">主键的值</param>
        public bool Oper_DelByDataKey(string DataKeyValue)
        {
            bool tempvalue = false;

            //执行删除
            try
            {
                int.Parse(DataKeyValue);
                ExecuteQuery("delete   [" + Myt.TableName + "] where  [" + Myt.TableDataKey + "] =" + DataKeyValue + "  " );

            }
            catch
            {
                errorInfo = "";
                ExecuteQuery("delete   [" + Myt.TableName + "] where  [" + Myt.TableDataKey + "] = '" + DataKeyValue + "'  " );
            }



            if (errorInfo == "")
            {
                tempvalue = true;
            }

            return tempvalue;
        }
        /// <summary>
        /// 传入要删除的主键的数组将一起删除
        /// </summary>
        /// <param name="DataKeyValue">主键的值</param>
        public bool Oper_DelByDataKey(int DataKeyValue)
        {
            bool tempvalue = false;

            //执行删除
            ExecuteQuery("delete  [" + Myt.TableName + "] where  [" + Myt.TableDataKey + "] =" + DataKeyValue + "  " );

            if (errorInfo == "")
            {
                tempvalue = true;
            }

            return tempvalue;
        }
        /// <summary>
        /// 传入删除的主键值删除对象
        /// </summary>
        /// <param name="DataKeyValue">传入主键的值</param>
        public bool Oper_DelByDataKey(DateTime DataKeyValue)
        {
            bool tempvalue = false;

            //执行删除
            ExecuteQuery("delete  [" + Myt.TableName + "] where  [" + Myt.TableDataKey + "] = '" + DataKeyValue + "'  " );

            if (errorInfo == "")
            {
                tempvalue = true;
            }

            return tempvalue;
        }
        /// <summary>
        /// 传入删除主键的数组值 string类型的数组
        /// </summary>
        /// <param name="DataKeyValue">传入删除的主键值 请使用 string[]数组</param>
        public bool Oper_DelByDataKey(string[] DataKeyValue)
        {
            bool tempvalue = false;

            string Cloumn = "";
            string Sqlstring = "";
            for (int i = 0; i < DataKeyValue.Length; i++)
            {
                Cloumn += DataKeyValue[i].ToString() + ",";
                Sqlstring += "'" + DataKeyValue[i].ToString() +"'" +",";
            }

            if (Cloumn != "")
            {
                Cloumn = Cloumn.Substring(0, Cloumn.Length - 1);
                Sqlstring = Sqlstring.Substring(0, Sqlstring.Length - 1);
            }
            else
            {
                Cloumn = "000";
            }

            //执行删除
            ExecuteQuery("delete  [" + Myt.TableName + "] where  [" + Myt.TableDataKey + "] in (" + Cloumn + ")  " );

            if (errorInfo == "")
            {
                tempvalue = true;
            }
            else
            {
                //执行删除
                ExecuteQuery("delete  [" + Myt.TableName + "] where  [" + Myt.TableDataKey + "] in (" + Sqlstring + ")  " );
                if (errorInfo == "")
                {
                    tempvalue = true;
                }
            }

            return tempvalue;
        }

        /// <summary>
        /// 是否存在该记录
        /// </summary>
        /// <param name="DataKeyValue">传入主键的值</param>
      public bool Oper_Exists(int DataKeyValue)
        {
            ///看看是不是大于0
            try
            {
                if (ExecuteQuery("select ["+Myt.TableDataKey+"] from  [" + Myt.TableName + "]   where [" + Myt.TableDataKey + "] =" + DataKeyValue).Tables[0].Rows.Count > 0)
                {
                    return true;

                }
            }
            catch 
            {

                return false;
            }
            return false;
        }

        /// <summary>
        /// 是否存在该记录
        /// </summary>
        /// <param name="DataKeyValue">传入主键的值</param>
      public bool Oper_Exists(DateTime DataKeyValue)
      {
            ///看看是不是大于0
            try
            {
                if (ExecuteQuery("select  [" + Myt.TableDataKey + "]  from  [" + Myt.TableName + "]   where [" + Myt.TableDataKey + "] = '" + DataKeyValue + "'").Tables[0].Rows.Count > 0)
                {
                    return true;

                }
            }
            catch
            {

                return false;
            }
            return false;
        
        }


        /// <summary>
        /// 是否存在该记录
        /// </summary>
        /// <param name="DataKeyValue">传入主键的值</param>
      public bool Oper_Exists(string DataKeyValue)
        {
            ///看看是不是大于0
            try
            {
                if (ExecuteQuery("select  [" + Myt.TableDataKey + "]  from  [" + Myt.TableName + "]   where [" + Myt.TableDataKey + "] = '" + DataKeyValue + "'").Tables[0].Rows.Count > 0)
                {
                    return true;

                }
            }
            catch
            {

                return false;
            }
            return false;
        }

        /// <summary>
        /// 是否存在该记录
        /// </summary>
        /// <param name="DataObject">传入的数据对像</param>
      public bool Oper_Exists(T DataObject)
        {
            ///看看是不是大于0
            try
            {
                if (ExecuteQuery("select [" + Myt.TableDataKey + "]   from  [" + Myt.TableName + "]   where [" + Myt.TableDataKey + "] = '" + DataObject.GetType().GetProperty(Myt.TableDataKey).GetValue(DataObject, null) + "'").Tables[0].Rows.Count > 0)
                {
                    return true;

                }
            }
            catch
            {

                return false;
            }
            return false;
        }

                /// <summary>
        /// 是否存在该记录 查找指定的栏目的指定的值
        /// </summary>
        /// <param name="ColumnValue">栏目值</param>
        /// <param name="Column">栏目名</param>
        /// <returns></returns>
      public bool Oper_Exists(string ColumnValue, string Column)
      {
          SqlDataAdapter MyDa = new SqlDataAdapter("", TextData.SqlConnStr);
          MyDa.SelectCommand.Connection = TextData.MySql;
          MyDa.SelectCommand.CommandType = CommandType.Text;

          #region CX_Resume 的查询方法
          MyDa.SelectCommand.CommandText = "select [" + Column + "]   from  [" + Myt.TableName + "]   where [" + Column + "] = @" + Column;
          MyDa.SelectCommand.Parameters.Add(new SqlParameter("@" + Column, ColumnValue));
          #endregion
          DataSet MyDs = new DataSet();
          try
          {
              MyDa.Fill(MyDs);
          }
          catch (Exception ex)//資料填充時的異常處理
          {
              if (TextData.MySql.State == ConnectionState.Open)///ConnectionState 得到當前資料源聯接的狀態
              {
                  TextData.MySql.Close();
              }
              MyDs = null;
              ErrorInfo += "执行  是否存在该记录 查找指定的栏目的指定的值 操作 Oper_Exists(string ColumnValue, string Column) 时出现错误" + ex.Message;
          }

          if (TextData.MySql.State == ConnectionState.Open)///ConnectionState 得到當前資料源聯接的狀態
          {
              TextData.MySql.Close();

          }
          
          ///看看是不是大于0
          try
          {
              if (MyDs.Tables[0].Rows.Count > 0)
              {
                  return true;
              }
          }
          catch
          {

              return false;
          }
          return false;

      }


        #region 数据转对象
        /// <summary>
        ///  传入读出数据的条数 条件
        ///  返回  类型的数组
        /// </summary>
        /// <param name="RecordNum">读出条数</param>
        /// <param name="Where">条件 如 newsid!="" and 0=0 </param>
        /// <returns></returns>
        public T[] Oper_SelectToObject(int RecordNum, string Where)
        {
            return (T[])ConvertToObject(OperSelectN(new String[] { }, RecordNum, Where));
        }
        /// <summary>
        ///  传入读出数据的条数 
        ///  返回  类型的数组
        /// </summary>
        /// <param name="RecordNum">读出条数</param>
        /// <returns></returns>
        public T[] Oper_SelectToObject(int RecordNum)
        {
            return (T[])ConvertToObject(OperSelectN(new String[] { }, RecordNum));
        }
        #endregion



        #endregion

        /// <summary>
        /// 把对应表的数据转成对象
        /// </summary>
        /// <param name="MyDs">传入的dataset</param>
        /// <returns></returns>
        private T[] ConvertToObject(DataSet MyDs)
        {
            DataTable Mydt = MyDs.Tables[0];

            //定义一个方法用于显示数据 类型的集合
            T[] p = new T[1];
            if (Mydt.Rows.Count == 0)
            {
                p[0] = Myt;
            }
            else
            {
                p = new T[Mydt.Rows.Count];
            }

            try
            {
                for (int i = 0; i < Mydt.Rows.Count; i++)
                {

                    object Mydato = Activator.CreateInstance(Myt.GetType());//实例化新对像

                    #region 实现转换的方法

                    ///开始使用方法传入属性值
                    foreach (System.Reflection.PropertyInfo Proper in Myt.GetType().GetProperties())
                    {
                        if (Proper.Name != "TableName" && Proper.Name != "TableDataKey")//删除接口的两个默认属性
                        {
                            Mydato.GetType().GetProperty(Proper.Name).SetValue(Mydato,
                                //传值
                                //  Mydt.Rows[i][Proper.Name].GetType().ToString() 得到当前的类型
                                // Myt.GetType().GetProperty(Proper.Name).GetValue(Myt, null);//返回默认值
                                // Mydt.Rows[i][Proper.Name] 得到当前的值
                                Mydt.Rows[i][Proper.Name].GetType().ToString() == System.DBNull.Value.GetType().ToString() ? Myt.GetType().GetProperty(Proper.Name).GetValue(Myt, null) : Mydt.Rows[i][Proper.Name]
                                , null);
                        }
                        else
                        {
                            //设定值
                            Mydato.GetType().GetProperty(Proper.Name).SetValue(Mydato,
                                Myt.GetType().GetProperty(Proper.Name).GetValue(Myt, null),
                                null);
                        }
                    }

                    #endregion
                    p[i] = (T)Mydato;


                }
            }
            catch (Exception ex)
            {
                errorInfo += "执行  把对应表的数据转成对象时出现错误" + ex.Message + ex.Source;
            }

            return p;
        }

        /// <summary>
        /// 得到传入对像的成员 返回下面所有的属性
        /// </summary>
        /// <param name="type">传入 实现 IDataBaseTable接口的数据库操作对像 </param>
        /// <returns></returns>
        private System.Reflection.PropertyInfo[] GetMembers(Type type)
        {

            MyDataTableMembers = new System.Reflection.PropertyInfo[type.GetProperties().Length - 2];//设定初始长度
            int i = 0;
            foreach (System.Reflection.PropertyInfo Proper in type.GetProperties())
            {
                if (Proper.Name != "TableName" && Proper.Name != "TableDataKey")//删除接口的两个默认属性
                {
                    MyDataTableMembers[i] = Proper;
                }
                i++;
            }

            return MyDataTableMembers;
        }

    }

}

namespace Tong.Data {

    /// <summary>
    /// CX_NEWS数据库操作类。
    /// </summary>
    public class Data_CX_NEWS:IDataBaseTable
    {
        private decimal cX_NEWS_id = 0;
        /// <summary>
        /// 
        /// </summary>
        public decimal CX_NEWS_id
        {
            get { return cX_NEWS_id; }
            set { cX_NEWS_id = value; }
        }
        public static string _CX_NEWS_id = "CX_NEWS_id";
        private string cX_NEWS_Name = "";
        /// <summary>
        /// 
        /// </summary>
        public string CX_NEWS_Name
        {
            get { return cX_NEWS_Name; }
            set { cX_NEWS_Name = value; }
        }
        public static string _CX_NEWS_Name = "CX_NEWS_Name";
        private decimal cX_NEWS_Class_id = 0;
        /// <summary>
        /// 新闻栏目
        /// </summary>
        public decimal CX_NEWS_Class_id
        {
            get { return cX_NEWS_Class_id; }
            set { cX_NEWS_Class_id = value; }
        }
        public static string _CX_NEWS_Class_id = "CX_NEWS_Class_id";
        private string cX_NEWS_Creater = "";
        /// <summary>
        /// 
        /// </summary>
        public string CX_NEWS_Creater
        {
            get { return cX_NEWS_Creater; }
            set { cX_NEWS_Creater = value; }
        }
        public static string _CX_NEWS_Creater = "CX_NEWS_Creater";
        private string cX_NEWS_From = "";
        /// <summary>
        /// 
        /// </summary>
        public string CX_NEWS_From
        {
            get { return cX_NEWS_From; }
            set { cX_NEWS_From = value; }
        }
        public static string _CX_NEWS_From = "CX_NEWS_From";
        private string cX_NEWS_Top = "";
        /// <summary>
        /// 头条新闻
        /// </summary>
        public string CX_NEWS_Top
        {
            get { return cX_NEWS_Top; }
            set { cX_NEWS_Top = value; }
        }
        public static string _CX_NEWS_Top = "CX_NEWS_Top";
        private string cX_NEWS_Pic = "";
        /// <summary>
        /// 
        /// </summary>
        public string CX_NEWS_Pic
        {
            get { return cX_NEWS_Pic; }
            set { cX_NEWS_Pic = value; }
        }
        public static string _CX_NEWS_Pic = "CX_NEWS_Pic";
        private string cX_NEWS_Pic_Url = "";
        /// <summary>
        /// 图片url
        /// </summary>
        public string CX_NEWS_Pic_Url
        {
            get { return cX_NEWS_Pic_Url; }
            set { cX_NEWS_Pic_Url = value; }
        }
        public static string _CX_NEWS_Pic_Url = "CX_NEWS_Pic_Url";
        private DateTime cX_NEWS_PublicTime = DateTime.Now;
        /// <summary>
        /// 发布时间
        /// </summary>
        public DateTime CX_NEWS_PublicTime
        {
            get { return cX_NEWS_PublicTime; }
            set { cX_NEWS_PublicTime = value; }
        }
        public static string _CX_NEWS_PublicTime = "CX_NEWS_PublicTime";
        private string cX_NEWS_Cont = "";
        /// <summary>
        /// 新闻内容
        /// </summary>
        public string CX_NEWS_Cont
        {
            get { return cX_NEWS_Cont; }
            set { cX_NEWS_Cont = value; }
        }
        public static string _CX_NEWS_Cont = "CX_NEWS_Cont";
        private decimal cX_NEWS_Sort = 0;
        /// <summary>
        /// 
        /// </summary>
        public decimal CX_NEWS_Sort
        {
            get { return cX_NEWS_Sort; }
            set { cX_NEWS_Sort = value; }
        }
        public static string _CX_NEWS_Sort = "CX_NEWS_Sort";
        private string cx_keyWord_Name = "";
        /// <summary>
        /// keyword
        /// </summary>
        public string Cx_keyWord_Name
        {
            get { return cx_keyWord_Name; }
            set { cx_keyWord_Name = value; }
        }
        public static string _Cx_keyWord_Name = "Cx_keyWord_Name";
        private string cX_NEWS_Title = "";
        /// <summary>
        /// 
        /// </summary>
        public string CX_NEWS_Title
        {
            get { return cX_NEWS_Title; }
            set { cX_NEWS_Title = value; }
        }
        public static string _CX_NEWS_Title = "CX_NEWS_Title";
        private string cX_NEWS_KeyWords = "";
        /// <summary>
        /// 
        /// </summary>
        public string CX_NEWS_KeyWords
        {
            get { return cX_NEWS_KeyWords; }
            set { cX_NEWS_KeyWords = value; }
        }
        public static string _CX_NEWS_KeyWords = "CX_NEWS_KeyWords";
        private string cX_NEWS_Description = "";
        /// <summary>
        /// 
        /// </summary>
        public string CX_NEWS_Description
        {
            get { return cX_NEWS_Description; }
            set { cX_NEWS_Description = value; }
        }
        public static string _CX_NEWS_Description = "CX_NEWS_Description";
        private string cX_NEWS_Class_Edit = "";
        /// <summary>
        /// 
        /// </summary>
        public string CX_NEWS_Class_Edit
        {
            get { return cX_NEWS_Class_Edit; }
            set { cX_NEWS_Class_Edit = value; }
        }
        public static string _CX_NEWS_Class_Edit = "CX_NEWS_Class_Edit";

        private string tableName = "CX_NEWS";
        /// <summary>
        /// 数据库表名
        /// </summary>
        public string TableName
        {
            get { return tableName; }
            set { tableName = value; }
        }

        private string tableDataKey = "CX_NEWS_id";
        /// <summary>
        /// 数据库主键名
        /// </summary>
        public string TableDataKey
        {
            get { return tableDataKey; }
            set { tableDataKey = value; }
        }
    }

    /// <summary>
    ///  栏目表
    /// </summary>
    public class Data_CX_Column:IDataBaseTable
    {

        private decimal cX_Column_id = 0;
        /// <summary>
        /// 栏目自动编号
        /// </summary>
        public decimal CX_Column_id
        {
            get { return cX_Column_id; }
            set { cX_Column_id = value; }
        }
        public static string _CX_Column_id = "CX_Column_id";
        private decimal cX_Column_followid = 0;
        /// <summary>
        /// 栏目从属id
        /// </summary>
        public decimal CX_Column_followid
        {
            get { return cX_Column_followid; }
            set { cX_Column_followid = value; }
        }
        public static string _CX_Column_followid = "CX_Column_followid";
        private string cX_Column_Name = "";
        /// <summary>
        /// 栏目名
        /// </summary>
        public string CX_Column_Name
        {
            get { return cX_Column_Name; }
            set { cX_Column_Name = value; }
        }
        public static string _CX_Column_Name = "CX_Column_Name";
        private int cX_Column_Class = 0;
        /// <summary>
        /// 栏目分类
        /// </summary>
        public int CX_Column_Class
        {
            get { return cX_Column_Class; }
            set { cX_Column_Class = value; }
        }
        public static string _CX_Column_Class = "CX_Column_Class";
        private string cX_Column_Directory = "";
        /// <summary>
        /// 栏目目录
        /// </summary>
        public string CX_Column_Directory
        {
            get { return cX_Column_Directory; }
            set { cX_Column_Directory = value; }
        }
        public static string _CX_Column_Directory = "CX_Column_Directory";
        private string cX_Column_Explair = "";
        /// <summary>
        /// 栏目说明
        /// </summary>
        public string CX_Column_Explair
        {
            get { return cX_Column_Explair; }
            set { cX_Column_Explair = value; }
        }
        public static string _CX_Column_Explair = "CX_Column_Explair";
        private string cX_Column_ItemTemplate_Url = "";
        /// <summary>
        /// 栏目模板地址
        /// </summary>
        public string CX_Column_ItemTemplate_Url
        {
            get { return cX_Column_ItemTemplate_Url; }
            set { cX_Column_ItemTemplate_Url = value; }
        }
        public static string _CX_Column_ItemTemplate_Url = "CX_Column_ItemTemplate_Url";
        private string cX_Column_ItemTeplate_Parame = "";
        /// <summary>
        /// 
        /// </summary>
        public string CX_Column_ItemTeplate_Parame
        {
            get { return cX_Column_ItemTeplate_Parame; }
            set { cX_Column_ItemTeplate_Parame = value; }
        }
        public static string _CX_Column_ItemTeplate_Parame = "CX_Column_ItemTeplate_Parame";
        private int cX_Column_Sort = 0;
        /// <summary>
        /// 栏目排序
        /// </summary>
        public int CX_Column_Sort
        {
            get { return cX_Column_Sort; }
            set { cX_Column_Sort = value; }
        }
        public static string _CX_Column_Sort = "CX_Column_Sort";
        private string cX_CX_Column_Tab_Name = "";
        /// <summary>
        /// 栏目英文名 用于指定数据库表名
        /// </summary>
        public string CX_CX_Column_Tab_Name
        {
            get { return cX_CX_Column_Tab_Name; }
            set { cX_CX_Column_Tab_Name = value; }
        }
        public static string _CX_CX_Column_Tab_Name = "CX_CX_Column_Tab_Name";
        private int cX_Column_LX = 0;
        /// <summary>
        /// 数字类型  栏目类型 0 为一般栏目 显示分类 1 为新闻栏目用于新闻分类时使用 0 将不进行新闻生成
        /// </summary>
        public int CX_Column_LX
        {
            get { return cX_Column_LX; }
            set { cX_Column_LX = value; }
        }
        public static string _CX_Column_LX = "CX_Column_LX";
        private string cX_Column_Pic = "";
        /// <summary>
        /// 
        /// </summary>
        public string CX_Column_Pic
        {
            get { return cX_Column_Pic; }
            set { cX_Column_Pic = value; }
        }
        public static string _CX_Column_Pic = "CX_Column_Pic";


        private string tableName = "CX_Column";
        /// <summary>
        /// 数据库表名
        /// </summary>
        public string TableName
        {
            get { return tableName; }
            set { tableName = value; }
        }

        private string tableDataKey = "CX_Column_id";
        /// <summary>
        /// 数据库主键名
        /// </summary>
        public string TableDataKey
        {
            get { return tableDataKey; }
            set { tableDataKey = value; }
        }

  
    }

    /// <summary>
    /// CX_NEWS_Class数据库操作类。
    /// </summary>
    public class Data_CX_NEWS_Class : IDataBaseTable
    {
        private decimal cX_NEWS_Class_id = 0;
        /// <summary>
        /// 新闻设定 id
        /// </summary>
        public decimal CX_NEWS_Class_id
        {
            get { return cX_NEWS_Class_id; }
            set { cX_NEWS_Class_id = value; }
        }
        public static string _CX_NEWS_Class_id = "CX_NEWS_Class_id";
        private string cX_NEWS_Class_Name = "";
        /// <summary>
        /// 新闻设定名
        /// </summary>
        public string CX_NEWS_Class_Name
        {
            get { return cX_NEWS_Class_Name; }
            set { cX_NEWS_Class_Name = value; }
        }
        public static string _CX_NEWS_Class_Name = "CX_NEWS_Class_Name";
        private decimal cX_Column_id = 0;
        /// <summary>
        /// 新闻设定所属栏目
        /// </summary>
        public decimal CX_Column_id
        {
            get { return cX_Column_id; }
            set { cX_Column_id = value; }
        }
        public static string _CX_Column_id = "CX_Column_id";
        private string cX_NEWS_Class_Explier = "";
        /// <summary>
        /// 新闻设定说明
        /// </summary>
        public string CX_NEWS_Class_Explier
        {
            get { return cX_NEWS_Class_Explier; }
            set { cX_NEWS_Class_Explier = value; }
        }
        public static string _CX_NEWS_Class_Explier = "CX_NEWS_Class_Explier";
        private string cX_NEWS_Class_Itemplitate_Address = "";
        /// <summary>
        /// 模板地址
        /// </summary>
        public string CX_NEWS_Class_Itemplitate_Address
        {
            get { return cX_NEWS_Class_Itemplitate_Address; }
            set { cX_NEWS_Class_Itemplitate_Address = value; }
        }
        public static string _CX_NEWS_Class_Itemplitate_Address = "CX_NEWS_Class_Itemplitate_Address";
        private string cX_NEWS_Class_Itemplitate_Parame = "";
        /// <summary>
        /// 新闻模板参数
        /// </summary>
        public string CX_NEWS_Class_Itemplitate_Parame
        {
            get { return cX_NEWS_Class_Itemplitate_Parame; }
            set { cX_NEWS_Class_Itemplitate_Parame = value; }
        }
        public static string _CX_NEWS_Class_Itemplitate_Parame = "CX_NEWS_Class_Itemplitate_Parame";
        private string cX_NEWS_Class_Pic = "";
        /// <summary>
        /// 显示图片
        /// </summary>
        public string CX_NEWS_Class_Pic
        {
            get { return cX_NEWS_Class_Pic; }
            set { cX_NEWS_Class_Pic = value; }
        }
        public static string _CX_NEWS_Class_Pic = "CX_NEWS_Class_Pic";
        private string cX_NEWS_Class_CreateFielfront = "";
        /// <summary>
        /// 生成文件名前缀
        /// </summary>
        public string CX_NEWS_Class_CreateFielfront
        {
            get { return cX_NEWS_Class_CreateFielfront; }
            set { cX_NEWS_Class_CreateFielfront = value; }
        }
        public static string _CX_NEWS_Class_CreateFielfront = "CX_NEWS_Class_CreateFielfront";
        private string cX_NEWS_Class_Directory = "";
        /// <summary>
        /// 生成目录
        /// </summary>
        public string CX_NEWS_Class_Directory
        {
            get { return cX_NEWS_Class_Directory; }
            set { cX_NEWS_Class_Directory = value; }
        }
        public static string _CX_NEWS_Class_Directory = "CX_NEWS_Class_Directory";
        private string tableName = "CX_NEWS_Class";

        /// <summary> 
        /// 数据库表名 
        /// </summary> 
        public string TableName
        {
            get { return tableName; }
            set { tableName = value; }
        }
        private string tableDataKey = "CX_NEWS_Class_id";
        /// <summary>
        /// 数据库表名 
        /// </summary>
        public string TableDataKey
        {
            get { return tableDataKey; }
            set { tableDataKey = value; }
        }

    }  
 
}










public class Conts
{
    private string myString = "";

    /// <summary>
    /// 字符串
    /// </summary>
    public string MyString
    {
        get { return myString; }
        set { myString = value; }
    }
}

/// <summary>
/// 数据显示
/// </summary>
public class TestClass
{
    /// <summary>
    /// 输入加入的字符串
    /// </summary>
    /// <param name="MyString">传入字符串</param>
    /// <returns></returns>
    public object StrinObj(string MyString)
    {
        object Myobj = Activator.CreateInstance(typeof(Conts));//new 一个 Conts对像

        #region 对像一个显示
        Myobj.GetType().GetProperty("MyString").SetValue(Myobj, MyString, null);
        #endregion

        return Myobj;
    }
}